package com.boscloud.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.boscloud.pojo.PostGoodMvtResult;
import com.boscloud.pojo.RawMaterialInboundInfo;
import com.boscloud.pojo.RawMaterialInboundInfoDetail;
import com.boscloud.service.RawMaterialInboundInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@CrossOrigin //允许跨域
@RestController
public class RawMaterialInboundController {
    @Autowired
    private RawMaterialInboundInfoService RawMaterialInboundInfoService;
    @PostMapping("/RawMaterialInboundDetails")//扫描条码--获取原料入库信息
    public List<RawMaterialInboundInfo> getRawMaterialInboundDetails(@RequestBody Map<String, Object> params) throws IOException {
        Map<String, String> headers = new HashMap<String, String>();
        headers.put("PORTID","ITMS001");//接口ID
        return RawMaterialInboundInfoService.getRawMaterialInboundDetails(params,headers);
    }
    @PostMapping("/PostRawMaterialInbound")//原料入库
    public List<PostGoodMvtResult> PostRawMaterialInbound(@RequestBody RawMaterialInboundInfo RawMaterialInboundInfo) throws IOException {
        Map<String, String> headers = new HashMap<String, String>();
        headers.put("PORTID","ITMS003");//接口ID
        Map<String, Object> params  = JSONObject.parseObject(JSON.toJSONString(RawMaterialInboundInfo));
        return RawMaterialInboundInfoService.PostRawMaterialInbound(params,headers);
    }
}
